package com.swf.seed.algorithms.problem;

/**
 * ClassName: Armstrong <br/>
 * Function: 阿姆斯壮数. <br/>
 * Reason: 在三位的整数中，例如153可以满足1^3+5^3+3^3=153，这样的数称之为Armstrong数，
 * 试写出一程式找出所有的三位数Armstrong数. <br/>
 * date: 2015-1-20 下午4:15:12 <br/>
 * 
 * @author shenwf10476
 * @version
 * @since JDK 1.6
 */
public class Armstrong {
	boolean count(int n){
		int c = n%10;
		int b = n/10%10;
		int a = n/100;
		boolean r = ( n==a*a*a+b*b*b+c*c*c);
		if (r){
			System.out.println(n + " = " + a + "^3" + " + " + b + "^3 "+ "+ "+ c  + "^3");
		}
		return r;
	}
	
	public static void main(String[] args) {
		Armstrong armstrong = new Armstrong();
		for (int i=100;i<1000;i++){
			armstrong.count(i);
		}
	}
}
